<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok=""
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="close"
    cancelText="关闭">
  <a-card :bordered="false">
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="add" type="primary" icon="plus">添加等级任务</a-button>
    </div>

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>

      </a-table>
    </div>

    <level-tasks-modal ref="modalForm" @ok="modalFormOk"></level-tasks-modal>
  </a-card>
  </j-modal>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import LevelTasksModal from './modules/LevelTasksModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'LevelTasksList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      LevelTasksModal
    },
    data () {
      return {
        title:'等级任务',
        width:800,
        visible: false,
        disableSubmit: true,
        description: '等级任务管理页面',
        parentId:"",
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          /*{
            title:'奖励规则父级id',
            align:"center",
            dataIndex: 'parentId'
          },
          {
            title:'任务编号',
            align:"center",
            dataIndex: 'taskCode'
          },
          {
            title:'任务名称',
            align:"center",
            dataIndex: 'taskName'
          },*/
          {
            title:'任务描述',
            align:"center",
            dataIndex: 'taskDescribe'
          },
          /*{
            title:'任务推广值',
            align:"center",
            dataIndex: 'value'
          },*/
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/system/levelTasks/list",
          delete: "/system/levelTasks/delete",
          deleteBatch: "/system/levelTasks/deleteBatch",
          exportXlsUrl: "/system/levelTasks/exportXls",
          importExcelUrl: "system/levelTasks/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
        disableMixinCreated:true,
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //初始化数据
      initData(parentId){
        this.queryParam.parentId=parentId;
        this.loadData(1);
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'parentId',text:'奖励规则父级id',dictCode:''})
        fieldList.push({type:'string',value:'taskCode',text:'任务编号',dictCode:'level_tasks'})
        fieldList.push({type:'string',value:'taskName',text:'任务名称',dictCode:''})
        fieldList.push({type:'string',value:'taskDescribe',text:'任务描述',dictCode:''})
        fieldList.push({type:'string',value:'value',text:'任务推广值',dictCode:''})
        this.superFieldList = fieldList
      },
      //关闭
      close () {
        this.$emit('close');
        this.visible = false;
      },
      add: function () {
        this.$refs.modalForm.add({parentId:this.parentId});
        this.$refs.modalForm.dataList=this.dataSource;
        this.$refs.modalForm.title = "新增";
        this.$refs.modalForm.disableSubmit = false;
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>